<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>工程竣工验收 - 监督申请</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">
    <style>
        body {
            height: auto;
        }

        .content {
            padding: 20px;
        }
        .layui-container {
            padding-top: 20px;
            width: auto;;
        }

        /*单元格备注样式*/
        .layui-table td.tdBz {
            text-align: left;
            padding-left: 0;
            border-left: none;
            color: #aaa;
        }

        .padNone .layui-form-select .layui-input {
            padding-right: 0;
        }

        .hide {
            display: none;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <form id="form" class="layui-form layui-form-pane" action="" lay-filter="example">
        <input type="hidden" name="prjId" class="formData" value="">
        <input type="hidden" name="id" class="formData" value="">

        <!--验收领导小组-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">项目信息</h2>
                <div class="layui-colla-content layui-show">
                    <table class="layui-table v-table">
                        <tbody>
                        <tr class="hide">
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                        </tr>
                        <tr>
                            <td class="th8">项目名称</td>
                            <td colspan="2">
                                <input name="prjName" lay-verify="isEmpty" type="text"
                                       class="layui-input formData" placeholder="项目名称" autocomplete="off" readonly>
                            </td>
                            <td class="th8 required">验收日期</td>
                            <td colspan="2">
                                <input name="aptDate" id="aptDate" placeholder="验收日期" autocomplete="off" class="layui-input formData" lay-verify="required" readonly>
                            </td>
                        </tr>
                        <tr>

                        </tr>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>



        <!--验收领导小组-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">验收领导小组</h2>
                <div class="layui-colla-content layui-show">
                    <table class="layui-table v-table">
                        <tbody>
                        <tr class="hide">
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                            <td width="24%"></td>
                            <td width="13%"></td>
                            <td width="13%"></td>
                        </tr>
                        <tr>
                            <td class="th8">组长</td>
                            <td colspan="2">
                                <input name="leader" lay-verify="isEmpty" type="text"
                                       class="layui-input formData" placeholder="组长名称" autocomplete="off">
                            </td>
                            <td class="th8">副组长</td>
                            <td colspan="2">
                                <input name="deputyLeader" lay-verify="isEmpty" type="text"
                                       class="layui-input formData" placeholder="副组长名称" autocomplete="off">
                            </td>
                        </tr>
                        <tr>
                            <td class="th8 required">成员</td>
                            <td colspan="5">
                                <input name="members" type="text" lay-verify="isEmpty|uname" class="layui-input formData"
                                       placeholder="成员名称" autocomplete="off">
                            </td>
                        </tr>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>


        <!--各专业验收组-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">各专业验收组</h2>
                <div class="layui-colla-content layui-show">
                    <script type="text/html" id="toolbarOrg">
                        <div class="layui-btn-container">
                            <button class="layui-btn" lay-event="add">新建</button>
                        </div>
                    </script>
                    <script type="text/html" id="barDemo">
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="delete">删除</a>
                    </script>
                    <table class="layui-hide" id="dataList" lay-filter="dataList"></table>

                </div>
            </div>
        </div>

        <!--质量文件与质量保证资料-->
        <div class="layui-collapse">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">质量文件与质量保证资料</h2>
                <div class="layui-colla-content layui-show">
                    <script type="text/html" id="toolbarOrg1">
                        <div class="layui-btn-container">
                            <button class="layui-btn" lay-event="add">上传文件</button>
                        </div>
                    </script>
                    <script type="text/html" id="barDemo1">
                        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="delete">删除</a>
                    </script>
                    <table class="layui-hide" id="dataList1" lay-filter="dataList1"></table>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="/static/js/main.js"></script>
<script type="text/javascript">
    var $;
    layui.use(['jquery', 'element', 'form', 'laydate', 'configure', 'configureCom', 'selectFun', 'bluebird', 'replaceStr', 'jsDictFile', 'mapExtend'], function () {
        $ = layui.jquery;
        var element = layui.element;
        var form = layui.form;
        var configure = layui.configure;
        var table = layui.table;
        var configureCom = layui.configureCom;
        var laydate = layui.laydate;
        var selectFun = layui.selectFun;
        var sessionFun = layui.sessionFun;//存储session

        laydate.render({
            elem: '#aptDate',
            type: 'date'
        });


        var prjId = sessionFun.get('prjId');
        //var project = sessionFun.get( 'PRJ_PROJECT_ENTITY');
        configureCom.getAjax(configure.PRJ_PROJECT_VIEW_API,{ prjId:prjId } ).then(function(res){
            if(!res.data){
                res.data = { prjId: prjId};
            }
            form.val('example', res.data);
        })



        configureCom.getAjax(configure.CPT_ACCEPTANCE_VIEW_API,{ prjId: prjId } ).then(function(res){
            if(!res.data){
                res.data = { prjId: prjId};
            }
            form.val('example', res.data);
        })



        /**
         * 验收专业小组
         */
        var cols = [[
            {field: 'specialty', title: '专业名称'},
            {field: 'leader', title: '组长' },
            {field: 'members', title: '组员'},
            {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 320}
        ]];
        configureCom.tableRenderGet(configure.CPT_ACCEPTANCE_TEAM_LIST_API, {prjId: prjId}, cols, 'dataList', 10, '', 'toolbarOrg',false);
        //头工具栏事件
        table.on('toolbar(dataList)', function (obj) {
            switch (obj.event) {
                case 'add':
                    editItem('专业验收小组', configure.CPT_ACCEPTANCE_TEAM_EDIT_HTML, configure.CPT_ACCEPTANCE_TEAM_SAVE_API);
                    break;
            }
        });


        /**
         * 附件列表
         */
        var table2 = {
            id:'dataList1',
            cols:[[
                {field: 'name', title: '文件名称'},
                {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 320}
            ]],
            url:configure.SYS_DOC_ATTS_API,
            data:{
                businessId:prjId,
                code:'CPT_ACCPTANCE_FILES'
            },
            page:false
        }
        configureCom.tableRenderGet(table2.url, table2.data, table2.cols, table2.id, 10, '', 'toolbarOrg1',table2.page);

        //头工具栏事件
        table.on('toolbar(dataList1)', function (obj) {
            switch (obj.event) {
                case 'add':
                    sessionFun.set(configure.SESSION_UPLOAD_CONFIG,{
                        url:configure.COMMON_UPLOAD_API,
                        formData:{
                            businessId:prjId,
                            code:'CPT_ACCPTANCE_FILES'
                        }
                    });
                    top.layer.open({
                        type: 2,
                        title: '上传附件',
                        content: configure.COMMON_UPLOAD_HTML,
                        area: configureCom.Psize1,
                        cancel: function (index, layero) {
                            configureCom.tableReloadById(table2.id);
                        }
                    });
                    break;
            }
        });





        //查看详情字典详情
        function editItem(title, htmlUrl, srvUrl) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize2,
                content: configureCom.nocache(htmlUrl),
                btn: ['保存'],
                yes: function (index, layero) {
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData();
                    configureCom.postDataAjax(srvUrl, data).then(function (res) {
                        if (res.code == 0) {
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                        } else {
                            top.layer.alert('保存失败！');
                        }
                    });
                }
            });
        }
    });

    function getData() {
        return new Promise(function (res, rej) {
            var data = {};
            if (!window.formVerifyFun()) {
                //return false;
            }

            $('.formData').each(function (index, item) {
                var key = $(item).attr('name');
                data[key] = $(item).val();
            });
            res({result: data});
        });
    }

</script>
</body>
</html>
